package com.swanclouds.redfish.internal;

import com.swanclouds.api.types.ServiceType;
import com.swanclouds.core.transport.ClientConstants;
import com.swanclouds.model.common.redfish.CollectionResource;
import com.swanclouds.redfish.common.redfish.CollectionResourceModel;

/**
 * @author 李文强
 *
 */
public class BaseTaskService extends BaseRedfishService{

    public BaseTaskService(){
        super(ServiceType.TASKS);
    }

    private static ThreadLocal<String> taskContainer = new ThreadLocal<>();

    public String getTaskId() {
        if (taskContainer.get() != null) {
            return taskContainer.get();
        }
        CollectionResource resource = get(CollectionResourceModel.class, uri(ClientConstants.PATH_TASKSERVICE)).execute();
        return getResourceId(resource, taskContainer);
    }
}
